window.httpRequest = function (url, data, callback, failure) {
    data['location_href'] = window.location.href;
    $.ajax({
        url: url,
        data: data,
        headers: { 'Authorization': $.cookie('wechat_auth') },
        type: "POST",
        dataType: "json",
        success: function (data) {
            //console.log(data);
            //后台业务逻辑错误
            if (data.code !== 0) {
                if (data.code === 4) {
                    window.location.href = data.data;
                } else {
                    //展示后台返回的错误原因
                    alert(data.msg ? data.msg : '服务器响应异常，请稍后再试');
                    if (failure) {
                        failure(data.code);
                    }
                }
                return;
            }
            //操作成功
            if (callback) {
                callback(data.data);
            }
        },
        error: function () {
            alert('网络异常，请稍后再试');
        }
    });
};
window.getQueryString = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}